﻿#include"my_algor_base.h"
#include<iostream>
#include <opencv2/opencv.hpp>


const char* SkyDetectAlgor::Algorithm_Name() {
	// 返回算法库名称
	return "SkyDetectAlgor";
}

const char* SkyDetectAlgor::Algorithm_Version() {
	// 返回版本号
	return "Ver.1.0";
}

SkyDetectAlgor::SkyDetectAlgor()
{
	obtracker  = new DETECTTRACK();
}

SkyDetectAlgor::~SkyDetectAlgor(){
	delete obtracker;
}


int SkyDetectAlgor::Algorithm_Init(const char* CfgPath){
	return 0;
}


int SkyDetectAlgor::Algorithm_RunCfg(DetectRect* rect){
	return 0;
}


int SkyDetectAlgor::Algorithm_Reset(){
	return 0;
}


int SkyDetectAlgor::Algorithm_DoProcess(ss_video_frame* frame, std::vector<DetectRect>* resultIN, std::vector<DetectRect>* resultOUT){

	cv::Mat cvMono(1024,1280,CV_8UC1,frame->virt_addr[0]);


	
	cv::Rect rectsNms;
	//get_sky_object_track(frame->img, centTrack1, rectsNms);
	obtracker->update(cvMono, rectsNms);
	//get_sky_object_track(cvMono, centTrack1, rectsNms);


	//for(size_t i(0);i<rectsNms.size() && i < 16 ;i++){
		//INFO_PRT("rectsNms x %d,y %d,w %d,h %d\n",rectsNms[i].x,rectsNms[i].y,rectsNms[i].width,rectsNms[i].height);
		DetectRect rect;
		rect.point[0][0] = rectsNms.x;
		rect.point[0][1] = rectsNms.y;

		rect.point[1][0] = rectsNms.x + rectsNms.width;
		rect.point[1][1] = rectsNms.y;

		rect.point[2][0] = rectsNms.x;
		rect.point[2][1] = rectsNms.y + rectsNms.height;

		rect.point[3][0] = rectsNms.x + rectsNms.width;
		rect.point[3][1] = rectsNms.y + rectsNms.height;

		resultOUT->push_back(rect);
	//}

	return 0;
}



